package com.lakeworks.common.enums;

import com.lakeworks.common.exception.response.ResponseException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;

import static com.lakeworks.common.enums.ResponseEnum.VALUE_NO_EXIST;
import static java.util.Arrays.stream;

@Getter
@AllArgsConstructor
public enum PickupType {

    PENDING("1", "在途"),

    SIGNFOFF("2", "已签收"),

    VERIFY("3", "核查中"),

    RECEIVED("4", "已入厂"),

    CANCEL("5","已取消");

    private final String value;

    private final String name;

    private static final HashMap<String, PickupType> map = new HashMap<>(8);

    static {
        stream(values()).forEach(pickupType -> map.put(pickupType.value, pickupType));
    }

    public static PickupType instance(String value) {
        if (!map.containsKey(value))
            throw new ResponseException(VALUE_NO_EXIST);
        return map.get(value);
    }
}
